| Total Complexity | 5 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm'; |
||
| 2 | |||
| 3 | @Entity() |
||
| 4 | export class ShippingCost { |
||
| 5 | @PrimaryGeneratedColumn('uuid') |
||
| 6 | private id: string; |
||
| 7 | |||
| 8 | @Column({ type: 'integer', nullable: false, default: 0 }) |
||
| 9 | private grams: number; |
||
| 10 | |||
| 11 | @Column({ type: 'integer', nullable: false, default: 0 }) |
||
| 12 | private price: number; |
||
| 13 | |||
| 14 | constructor(grams: number, price: number) { |
||
| 15 | this.grams = grams; |
||
| 16 | this.price = price; |
||
| 17 | } |
||
| 18 | |||
| 19 | public getId(): string { |
||
| 20 | return this.id; |
||
| 21 | } |
||
| 22 | |||
| 23 | public getGrams(): number { |
||
| 24 | return this.grams; |
||
| 25 | } |
||
| 26 | |||
| 27 | public getPrice(): number { |
||
| 28 | return this.price; |
||
| 29 | } |
||
| 30 | |||
| 31 | public getPriceFromCents(): number { |
||
| 32 | return this.price / 100; |
||
| 33 | } |
||
| 34 | |||
| 35 | public update(grams: number, price: number): void { |
||
| 36 | this.grams = grams; |
||
| 37 | this.price = price; |
||
| 38 | } |
||
| 40 |